package com.xckj.teacher.global;

import com.xckj.teacher.bean.AboutBean;
import com.xckj.teacher.bean.BaseBean;
import com.xckj.teacher.bean.ClassBean;
import com.xckj.teacher.bean.ClassDetailBean;
import com.xckj.teacher.bean.ContactBean;
import com.xckj.teacher.bean.GradeResetPassBean;
import com.xckj.teacher.bean.HomeBean;
import com.xckj.teacher.bean.HomeWorkBean;
import com.xckj.teacher.bean.LoginBean;
import com.xckj.teacher.bean.LoginParam;
import com.xckj.teacher.bean.RoomReportBean;
import com.xckj.teacher.bean.SearchBookBean;
import com.xckj.teacher.bean.TextbookBean;
import com.xckj.teacher.bean.UnitBean;
import com.xckj.teacher.bean.UpdateBean;
import com.xckj.teacher.bean.UserInfoBean;

import java.util.List;

import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;

/**
 * @Author: ChenYao
 * @Describe: API接口
 * @Date: 2024/4/10 22:59
 */
public interface ApiService {

    /**
     * 更新
     *
     * @param platform        平台
     * @param current_version 当前版本
     * @return 更新的数据
     */
    @FormUrlEncoded
    @POST("common/checkTeacherversion")
    Call<BaseBean<UpdateBean>> update(@Field("platform") String platform, @Field("current_version") String current_version);

    /**
     * 获取首页数据
     *
     * @return 首页数据
     */
    @GET("teacher/index")
    Call<BaseBean<HomeBean>> getHome();

    /**
     * 获取教材
     *
     * @return 教材数据
     */
    @GET("textbook/textbooksp")
    Call<BaseBean<List<TextbookBean>>> getTextbook();


    /**
     * 单元
     *
     * @param id 版本Id
     * @return 单元数据
     */
    @FormUrlEncoded
    @POST("textbook/unit")
    Call<BaseBean<List<UnitBean>>> unit(@Field("id") String id);

    /**
     * 保存单元
     *
     * @param unitid    单元Id
     * @param versionId 版本Id
     * @return 单元数据
     */
    @FormUrlEncoded
    @POST("textbook/switchunit")
    Call<BaseBean> saveUnit(@Field("unitid") String unitid, @Field("versionId") String versionId);


    /**
     * 获取班级
     *
     * @return 获取班级
     */
    @POST("grade/index")
    Call<BaseBean<List<ClassBean>>> getClassList();


    @FormUrlEncoded
    @POST("new_homework/homework")
    Call<BaseBean<HomeWorkBean>> homework(@Field("start") String start, @Field("end") String end, @Field("class_id") String class_id, @Field("type") String type);

    @FormUrlEncoded
    @POST("new_homework/machine")
    Call<BaseBean<RoomReportBean>> machine(@Field("start") String start, @Field("end") String end, @Field("class_id") String class_id);

    @FormUrlEncoded
    @POST("grade/editGrade")
    Call<BaseBean<Object>> editGrade(@Field("id") String id, @Field("name") String name);

    @FormUrlEncoded
    @POST("grade/addGroup")
    Call<BaseBean<Object>> addGroup(@Field("student_ids") String student_ids, @Field("name") String name, @Field("class_id") String class_id);

    @FormUrlEncoded
    @POST("grade/delGroup")
    Call<BaseBean<Object>> deleteGroup(@Field("id") String id);

    @FormUrlEncoded
    @POST("grade/resetpassword")
    Call<BaseBean<GradeResetPassBean>> gradeResetPass(@Field("id") String id);

    @GET("grade/getClassInfo")
    Call<BaseBean<ClassDetailBean>> getClassDetail(@Query("id") String id);


    /**
     * 搜索书籍
     *
     * @param key      搜索关键字
     * @param page     页码
     * @param pageSize 条目数
     * @return 搜索书籍的结果
     */
    @FormUrlEncoded
    @POST("textbook/search")
    Call<BaseBean<List<SearchBookBean>>> searchBook(@Field("key") String key, @Field("page") int page, @Field("pageSize") int pageSize);

    @FormUrlEncoded
    @POST("index/addFeedback")
    Call<BaseBean<Object>> feedBack(@Field("content") String content);

    @FormUrlEncoded
    @POST("user/profile")
    Call<BaseBean<Object>> updateProfile(@Field("avatar") String avatar);

    @FormUrlEncoded
    @POST("sms/send")
    Call<BaseBean<Object>> sendSms(@Field("mobile") String mobile, @Field("event") String event);

    @FormUrlEncoded
    @POST("user/changemobile")
    Call<BaseBean<Object>> changeMobile(@Field("mobile") String mobile, @Field("mobile_captcha") String mobile_captcha, @Field("captcha_token") String captcha_token, @Field("captcha") String captcha);

    @FormUrlEncoded
    @POST("user/resetpwd")
    Call<BaseBean<Object>> resetpwd(@Field("oldpassword") String oldpassword, @Field("againpassword") String againpassword, @Field("newpassword") String newpassword);

    @GET("index/getTeacherAbout")
    Call<BaseBean<AboutBean>> about();

    @GET("index/connectUs")
    Call<BaseBean<ContactBean>> connectUs();

    @GET("user/getuserinfo")
    Call<BaseBean<UserInfoBean>> getUserInfo();


    @GET("common/captcha")
    Call<ResponseBody> getCaptcha(@Query("id") String id);

    @POST("user/login")
    Call<BaseBean<LoginBean>> login(@Body LoginParam param);

    @Multipart
    @POST("common/upload")
    Call<ResponseBody> uploadFile(@Part MultipartBody.Part file);
}
